<?php defined("MAIN_DIR") or die("No direct access");

require_once ADMIN.HEADFILE;
?>
<script type="text/javascript">
page = "city";
func = add_city;
</script>
<div align="left">
<h1>Список городов</h1><?php
$city_query = "select * from `city` order by `city_name`";

$limit = 10;
$city_res = mysql_query($city_query);
$count = mysql_num_rows($city_res);
$page = 1;
if (isset($_GET['page']))
	$page = $_GET['page'];
$max_page = ceil($count/$limit);
if ($max_page == 0)
	$max_page++;
if ($page > $max_page)
	$page = $max_page;
elseif ($page < 1)
	$page = 1;
$start_list = (ceil($page)-1)*$limit;
$city_query .= " limit $start_list,$limit";
$city_res = mysql_query($city_query);
$city_count = mysql_num_rows($city_res);
?>
<input type='text' id='search' />
<table cellpadding="5" cellspacing="0" class='light'>
	<tr id='header'>
		<td width="30px" style="border-bottom:1px gray solid">ID</td>
		<td width="200px" style="border-bottom:1px gray solid">Название</td>
		<td width="80px" style="border-bottom:1px gray solid">Включен</td>
		<td width="180px" style="border-bottom:1px gray solid">Действия</td>
	</tr><?php
	while ($city_row = mysql_fetch_array($city_res))
	{
		?><tr>
			<td><?php echo $city_row['city_id']?></td>
			<td><?php echo $city_row['city_name']?></td>
			<td><?php echo $city_row['power'] == 'on' ? "Да" : "Нет"; ?></td>
			<td>
				<a href='/admin/site/cities/edit/<?php echo $city_row['city_id']?>'>Редактировать</a> |
				<a onclick='return confirm_del()' href='/admin/site/cities/delete/<?php echo $city_row['city_id']?>'>Удалить</a>
			</td>
		</tr><?php
	}
?></table>
<br /><a href='/admin/site/cities/add/'>Добавить</a>
<br /><?php require_once APP."pageskin.php"; ?>
</div>

<?php require_once ADMIN.FOOTERFILE; ?>